def select_sort(nums, reverse=False):
    # 选择一个最小的，然后与未排序数组的第一个交换位置
    for i in range(len(nums) - 1):
        min_index = i
        for j in range(i + 1, len(nums)):
            if nums[j] < nums[i]:
                min_index = j
            nums[i], nums[min_index] = nums[min_index], nums[i]

    return nums[::-1] if reverse else nums


if __name__ == '__main__':
    print(select_sort([3, 4, 2, 1, 5, 6]))
    print(select_sort([3, 4, 2, 1, 5, 6], reverse=True))
    print(select_sort([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]))
    print(select_sort([10, 9, 8, 7, 11, 5, 4, 3, 2, 1],reverse=True))
